<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浮动</title>
    <style>
        /* 清除浮动之双伪元素 */
        /* .clearfix:before,*/
        .clearfix:after {
            content: "";
            display: table;
        }

        .clearfix:after {
            clear: both;
        }

        .clearfix {
            zoom: 1;
            /*ie6,7 专门清除浮动的样式*/
        } 

        /* 清除浮动之after伪元素 */
        .clearfix:after{ /*伪元素是行内元素 正常浏览器清除浮动方法*/
            content: "";
            display: block;
            height: 0;
            clear:both;
            visibility: hidden;
        }
        .clearfix:before{
            content: "11111";

        }



        .clearfix {
            *zoom: 1;
            /*ie6清除浮动的方式 *号只有IE6-IE7执行，其他浏览器不执行*/
        }
    </style>
    <style>
        .x {
            width: 100%;
            background-color: red;
            overflow: hidden;
            margin: 10px auto;
        }

        .x div {
            width: 150px;
            height: 150px;
            background-color: greenyellow;
            float: left;
        }
        .x div img{
            width: 150px;
            height: 150px;
        }

        .xx {
            width: 600px;
            height: 300px;
            background-color: hotpink;
        }
    </style>
</head>

<body>
    <div class="x">
        <div class="clearfix">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
    <div class="xx"></div>
</body>

</html>